<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>layui学习</title>
    <link rel="stylesheet" href="layui/css/layui.css"/>
    <script type="text/javascript" src="layui/layui.js"></script>
</head>
<body>
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo layui-hide-xs layui-bg-black">帅气逼人后台管理系统</div>

        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item layui-hide layui-show-md-inline-block">
                <a href="javascript:;">
                    <img src="image/code.jpg" class="layui-nav-img">
                </a>
                <dl class="layui-nav-child">
                    <dd><a href="">退出</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item" lay-header-event="menuRight" lay-unselect>
                <a href="javascript:;">
                    <i class="layui-icon layui-icon-more-vertical"></i>
                </a>
            </li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree" lay-filter="test">
                <li class="layui-nav-item layui-nav-itemed">
                    <a class="" href="javascript:;">地区管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:;" title="layui.jsp">学校管理</a></dd>
                        <dd><a href="javascript:;" title="goods.jsp">商品管理</a></dd>
                        <dd><a href="javascript:;" title="support.jsp">供应商管理</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">仓库管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:;">采购入库</a></dd>
                        <dd><a href="javascript:;">销售出库</a></dd>
                        <dd><a href="javascript:;">库存盘点</a></dd>
                    </dl>
                </li>
            </ul>
        </div>
    </div>

    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div style="padding: 15px;">
            <div class="layui-tab" id="demo" lay-filter="demo" lay-allowclose="true">
                <!-- 动态加载tab页 -->
                <ul class="layui-tab-title">
                </ul>
                <!-- 动态加载tab页中的内容 -->
                <div class="layui-tab-content">
                </div>
            </div>
        </div>
    </div>

    <div class="layui-footer">
        <!-- 底部固定区域 -->
        底部固定区域
    </div>
</div>

<script>
    //JS
    layui.use(['jquery','element'], function(){
        var $ = layui.jquery;
        var element = layui.element;
        $("a[title]").click(function (){
            //获取当前点击的title
            var url =  $(this).attr("title");
            //获取超链接的名称
            var title = $(this).text();
            //判断tab页是否已经存在
            var exists = $("li[lay-id='"+url+"']").length;
            if(exists == null || exists == ""){
                element.tabAdd('demo', {
                    title: title
                    //,content: '选项卡的内容' //支持传入html
                    ,content:'<iframe src='+url+' width="100%" height="800px" frameborder="0"></iframe>'
                    ,id: url   //等同lay-id
                });
                //选中
                element.tabChange('demo', url);
            }else{
                //选中
                element.tabChange('demo', url);
            }
        });
    });
</script>
</body>
</html>